{% extends '../search_result.html' %}

{% block page_title %}{{ user.name }}'s index page{% endblock page_title %}

{% block navbar_status %}
                <li class="active"><a href="#">个人信息<span class="sr-only">(current)</span></a></li>
                <li><a type="submit" href="/community/group" target="_blank">社区</a></li>
                <li><a type="submit" href="/community/question/?q=11" target="_blank">Github</a></li>
{% endblock navbar_status %}
{% block main_div %}
<div class="col-md-5 col-md-offset-4" style="text-align: center;">
{% if errormsg != None %}
<div class="alert alert-danger alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>ERROR:</strong> {{ errormsg }}
</div>
{% elif msg != None %}
<div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>Message:</strong> {{ msg }}
</div>  
{% endif %}
</div>

<div class="col-md-6 col-md-offset-3">
<form class="form-horizontal" id="userconfig" method="POST" action="/user/index/">
{% csrf_token %}
  <div class="form-group">
    <label for="inputuserid" class="col-sm-2 control-label">Uid</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputuserid" placeholder="Uid" value="{{ user.uid }}" readonly>
    </div>
  </div>
  <div class="form-group">
    <label for="inputusername" class="col-sm-2 control-label">Username</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputusername" placeholder="Username" value="{{ user.name }}" readonly>
    </div>
  </div>
  <div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">Email</label>
    <div class="col-sm-10">
    <div class="input-group">
      <input type="email" class="form-control" placeholder="请先保存修改后验证" value="{{ user.email }}" name="newemail">
      <span class="input-group-btn">
        <button class="btn btn-default" type="submit" form="userconfig" formaction="/user/index/?changemail=1">保存邮箱修改</button>
        {% if user.verifyemail == 0 %}
        <button class="btn btn-default" type="submit" form="userconfig" formaction="/user/index/?veremail=1">验证</button>
        {% else %}
        <button class="btn btn-default" type="button" disabled="disabled">已验证</button>
        {% endif %}
      </span>
    </div><!-- /input-group -->
    </div>
  </div>
  <div class="form-group">
    <label for="inputusername" class="col-sm-2 control-label">邮件提醒</label>
    <div class="col-sm-8">
        {% if user.verifyemail == 0 %}
        <select class="form-control" disabled="true">
            <option>请先验证邮箱</option>
        </select> 
        {% else %}
        <select class="form-control" name="acceptemail">
                <option value="3" {% if user.acceptemail == 3 %}selected="selected"{% endif %}>接收所有回复提醒</option>
                <option value="2" {% if user.acceptemail == 2 %}selected="selected"{% endif %}>仅不接收社区快速回复提醒</option>
                <option value="1" {% if user.acceptemail == 1 %}selected="selected"{% endif %}>不接收所有快速回复提醒</option>
                <option value="0" {% if user.acceptemail == 0 %}selected="selected"{% endif %}>不接收任何邮件提醒</option>
        </select>        
        {% endif %}
    </div>
    <button type="submit" class="btn btn-default navbar-left"{% if user.verifyemail == 0 %} disabled="disabled"{% endif %}>保存修改</button>
  </div>
</form>
</div>

{% endblock main_div %}